package com.atguigu.shiro.controller;

import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * className: PermissionsException
 * description:
 * date: 2024/6/18-12:12
 * <p>
 * project: shiro
 * package: com.atguigu.shiro.controller
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@ControllerAdvice
public class PermissionsException {

    @ResponseBody
    @ExceptionHandler(UnauthorizedException.class)
    public String unauthorizedException(Exception ex) {
        return "无权限";
    }

    @ResponseBody
    @ExceptionHandler(AuthorizationException.class)
    public String authorizationException(Exception ex) {
        return "权限认证失败";
    }
}
